//节流函数

export default function throttleFn(callback: Function, timer: number) {
  //创造起始时间戳
  let upTimer: number;
  return function (this: any, ...arg: any[]) {


    //记录时间
    let nowTimer = Date.now();

    if (nowTimer - upTimer < timer) {
      //跳出
      return;
    }
    upTimer = nowTimer;
    callback.call(this, ...arg);
  };
}
